<template>
  <div>
    <div class="box-card">
      <div class="box-header">
        <div class="header-content">
          <i class="el-icon-info"></i>
          <span>共{{ total }}条记录</span>
        </div>
      </div>
      <el-table
        label-width="150px"
        :data="tableData"
        style="width: 100%"
        :header-cell-style="{ background: '#f4f4f5' }"
      >
        <el-table-column prop="type" label="操作类型" align="center">
        </el-table-column>
        <el-table-column prop="author" label="操作人" align="center">
        </el-table-column>
        <el-table-column prop="title" label="执行结果" align="center">
        </el-table-column>
        <el-table-column prop="display_time" label="操作时间" align="center">
        </el-table-column>
        <el-table-column prop="reviewer" label="描述" align="center">
        </el-table-column>
      </el-table>
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="pagesize"
        :total="total"
        layout="sizes, prev, pager, next, jumper"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { list } from '@/api/example/table.js'
export default {
  data () {
    return {
      input: '',
      tableData: [],
      page: 1,
      pagesize: 20,
      total: 0,
      loading: false
    }
  },

  async created () {
    this.initTable()
  },

  methods: {
    async initTable () {
      const { data } = await list({
        page: this.page,
        pagesize: this.pagesize
      })
      console.log(data)
      this.tableData = data.items
      this.total = data.total
    },
    // pagesize改变时
    handleSizeChange (val) {
      this.pagesize = val
      this.page = 1
      this.initTable()
    },
    // page改变时
    handleCurrentChange (val) {
      this.page = val
      this.initTable()
    }
  }
}
</script>

<style scoped lang="less">
.box-card {
  margin: 20px;
  background-color: #fff;
  padding: 20px;
  .box-header {
    .header-top {
      height: 45px;
      margin-bottom: 10px;
      .header-left {
        display: flex;
        .header-btn {
          width: 60px;
          font-size: 12px;
        }
      }
      .header-right {
        width: 90px;
        height: 32px;
        font-size: 12px;
        float: right;
        margin-top: -36px;
        .el-icon-edit {
          margin-left: -6px;
        }
      }
    }
    .header-content {
      background-color: #f4f4f5;
      color: #909399;
      font-size: 13px;
      padding-left: 8px;
      height: 40px;
      line-height: 40px;
      margin-bottom: 20px;
      .el-icon-info {
        margin-right: 5px;
      }
    }
  }
  .edit1 {
    color: #409eff;
    background: #ecf5ff;
    border-color: #b3d8ff;
    &:hover {
      background-color: #409eff;
      color: #fff;
    }
  }
  .edit2 {
    color: #f56c6c;
    background: #fef0f0;
    border-color: #fbc4c4;
    &:hover {
      background-color: #f56c6c;
      color: #fff;
    }
  }
  .el-pagination {
    height: 40px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: 20px;
  }
}

.el-dialog {
  .el-form {
    width: 400px;
    margin: auto;
    .el-input {
      width: 310px;
      height: 35px;
    }
  }
  .dialog-footer {
    margin-top: 60px;
    text-align: center;
  }
}
</style>
